<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Share;
use App\Models\Seo;
use Illuminate\Http\Request;

class ShareController extends Controller {

    public function index(Request $request){
        $params = [
            'cid'    => (int)$request->get('cid',0),
        ];
        $lists = Share::getWebList($params['cid']);
        $seo = Seo::getSeo(11);
        $cates = Category::where('pid',2)->get()->toArray();
        return view('home.share.index',compact('lists','seo','params','cates'));
    }


    public function show(Request $request){
        $id = (int)$request->get('id',0);
        $info = Share::findOrFail($id);
        $seo = Seo::getSeo(11);
        $seo['title'] = $info['title'].'-'.$seo['title'];
        $cates = Category::where('pid',2)->get()->toArray();
        return view('home.share.show',compact('info','seo','cates'));
    }
}
